import { createRouter, createWebHistory } from 'vue-router'
<<<<<<< HEAD
import HomeView from '../views/HomeView.vue'
=======
>>>>>>> a4bf6cb (第一次提交)

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
<<<<<<< HEAD
      name: 'home',
      component: HomeView
    },
    {
      path: '/about',
      name: 'about',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/AboutView.vue')
    }
  ]
})

=======
      redirect: '/home/pro'
    },
    {
      path:"/ditu",
      name: '地图',
      component: () => import('../views/di-tu.vue'),
    },
    {
      path:"/home",
      name: '首页',
      component: () => import('../views/home-page.vue'),
      redirect: '/home/pro',
      children: [
        {
          path: '/home/pro',
          name: '首页',
          component: () => import('@/views/pro-list.vue')
        },
        {
          path: '/home/user',
          name: '组件',
          component: () => import('@/views/user-list.vue')
        },
        {
          path: '/home/advertising',
          name: '角色',
          component: () => import('@/views/advertising-list.vue')
        },
        {
          path: '/home/class',
          name: '员工',
          component: () => import('@/views/class-list.vue')
        },
        {
          path: '/home/permission',
          name: '权限',
          component: () => import('@/views/permission-list.vue')
        },
        {
          path: '/home/attendance',
          name: '考勤',
          component: () => import('@/views/attendance-list.vue')
        },
        {
          path: '/home/approval',
          name: '审批',
          component: () => import('@/views/approval-list.vue')
        },
        {
          path: '/home/salary',
          name: '工资',
          component: () => import('@/views/salary-list.vue')
        },
        {
          path: '/home/social',
          name: '社保',
          component: () => import('@/views/social-list.vue')
        }
      ]
    },
    {
      path: '/login',
      name: '登录页',
      component: () => import('../views/login-page.vue')
    }
  ]
})
// 全局前置守卫
router.beforeEach((to, from, next) => {
  const token = localStorage.getItem('token');
  if (to.path === '/login' && token) {
    next('/home/pro')
  } else if (to.path !== '/login' && !token) {
    next('/login')
  } else {
    next()
  }
})
>>>>>>> a4bf6cb (第一次提交)
export default router
